﻿@{
    MVC3BookStoreEntities BookStoreEntities = new MVC3BookStoreEntities();
    var Promotions = from book in BookStoreEntities.Books
                     join Per in BookStoreEntities.Promotions on book.ID equals Per.BookID
                     select book;
                     
    string sessionID = Convert.ToString(HttpContext.Current.Session[BookStore.Controllers.ShoppingCartController.CartSessionKey]);
    var CartItems = BookStoreEntities.Carts.Count(c => c.CartID == sessionID);
    var CartAmout = BookStoreEntities.Carts.Where(c => c.CartID == sessionID).Sum(c => c.Amount) ?? 0;
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<table border="0">
    <tr>
        <td style="vertical-align: top">
            <div class="left_content">
                @RenderBody()
            </div>
            <div class="clear">
            </div>
        </td>
        <td>
            <div class="right_content">
                <div class="languages_box">
                    <span class="red">Languages:</span> <a href="#" class="selected">
                        <img src="@Url.Content("~/Content/Images/gb.gif")" alt="" title="" border="0" /></a>
                    <a href="#">
                        <img src="@Url.Content("~/Content/Images/fr.gif")" alt="" title="" border="0" /></a>
                    <a href="#">
                        <img src="@Url.Content("~/Content/Images/de.gif")" alt="" title="" border="0" /></a>
                </div>
                <div class="currency">
                    <span class="red">Currency: </span><a href="#">GBP</a> <a href="#">EUR</a> <a href="#"
                        class="selected">USD</a>
                </div>
                <div class="cart">
                    <div class="title">
                        <span class="title_icon">
                            <img src="@Url.Content("~/Content/Images/cart.gif")" alt="" title="" /></span>My
                        cart</div>
                    <div class="home_cart_content">
                        @CartItems x items | <span class="red">TOTAL: @CartAmout$</span>
                        
                    </div>
                    <a href="@Url.Action("Index", "ShoppingCart")" class="view_cart">view cart</a>
                </div>
                <div class="title">
                    <span class="title_icon">
                        <img src="@Url.Content("~/Content/Images/bullet3.gif")" alt="" title="" /></span>About
                    Our Store</div>
                <div class="about">
                    <p>
                        <img src="@Url.Content("~/Content/Images/about.gif")" alt="" title="" class="right" />
                        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
                        incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.
                    </p>
                </div>
                <div class="right_box">
                    <div class="title">
                        <span class="title_icon">
                            <img src="@Url.Content("~/Content/Images/bullet4.gif")" alt="" title="" /></span>Promotions</div>
                    @{
                        foreach (var Item in Promotions)
                        {
                            string sImageFile = string.Empty;
                            if (File.Exists(Server.MapPath(string.Format("~/Content/Images/Book/{0}.jpg", Item.BookCode))))
                            {
                                sImageFile = Item.BookCode;
                            }
                            else
                            {
                                sImageFile = "nophoto";
                            }
                        <div class="new_prod_box">
                            <a href="@Url.Action("Detail", "Home", new { ItemID = Item.ID })">@Item.BookName </a>
                            <div class="new_prod_bg">
                                <span class="new_icon">
                                    <img src="@Url.Content("~/Content/Images/promo_icon.gif")" alt="" title="" /></span>
                                <a href="@Url.Action("Detail", "Home", new { ItemID = Item.ID })">
                                    <img src="@Url.Content(string.Format("~/Content/Images/Book/{0}.jpg", sImageFile))" alt="" title="" class="thumb" border="0" /></a>
                            </div>
                        </div>  
                        }
                        
                        
                    }
                </div>
                <div class="right_box">
                    <div class="title">
                        <span class="title_icon">
                            <img src= "@Url.Content("~/Content/Images/bullet5.gif")" alt="" title="" /></span>Categories</div>
                    <ul class="list">
                        @foreach (var cat in BookStoreEntities.Categories)
                        {
                            <li><a href="@Url.Action("Index", "Search", new { CatID = cat.ID })">@cat.CategoryName </a></li>
                        }
                    </ul>
                    <div class="title">
                        <span class="title_icon">
                            <img src="@Url.Content("~/Content/Images/bullet6.gif")" alt="" title="" /></span>Partners</div>
                    <ul class="list">
                        <li><a href="#">Connect Customers</a></li>
                        <li><a href="#">Earn a commission</a></li>
                        <li><a href="#">Add value to your web site</a></li>
                    </ul>
                </div>
            </div>
            <!--end of right content-->
        </td>
    </tr>
</table>
